// 文章相关接口模块
import { request } from '../utils/request.js'

/**
 * 说明：根据频道获取文章列表
 *
 * @params channel_id 频道id
 * @params timestamp 时间戳，请求新的推荐数据传当前的时间戳，请求历史推荐传指定的时间戳
*/
export const getArticleList = params => request({
  method: 'GET',
  url: '/v1_0/articles',
  params
})

/**
 * 说明：获取文章详情
 *
 * @params articleId 文章id
*/
export const getArticleById = articleId => request({
  method: 'GET',
  url: `/v1_0/articles/${articleId}`
})

/**
 * 说明：收藏文章
 *
 * @params target 需要收藏的文章id
*/
export const addCollect = data => request({
  method: 'POST',
  url: '/v1_0/article/collections',
  data
})

/**
 * 说明：取消收藏文章
 *
 * @params target 需要取消收藏的文章id
*/
export const deleteCollect = target => request({
  method: 'DELETE',
  url: `/v1_0/article/collections/${target}`
})

/**
 * 说明：点赞文章
 *
 * @params target 需要点赞的文章id
*/
export const addlike = data => request({
  method: 'POST',
  url: '/v1_0/article/likings',
  data
})

/**
 * 说明：取消点赞文章
 *
 * @params target 需要取消收藏点赞的文章id
*/
export const deleteLike = target => request({
  method: 'DELETE',
  url: `/v1_0/article/likings/${target}`
})
